aboutsummaryrefslogtreecommitdiff
path: root/src/app/(main)/websites/[websiteId]/segments/SegmentsDataTable.tsx
blob: c1ba82ebbc3c3ea239e6cf944cb7d4f5a414e430 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import { DataGrid } from '@/components/common/DataGrid';
import { useWebsiteSegmentsQuery } from '@/components/hooks';
import { SegmentAddButton } from './SegmentAddButton';
import { SegmentsTable } from './SegmentsTable';

export function SegmentsDataTable({ websiteId }: { websiteId?: string }) {
  const query = useWebsiteSegmentsQuery(websiteId, { type: 'segment' });

  const renderActions = () => {
    return <SegmentAddButton websiteId={websiteId} />;
  };

  return (
    <DataGrid
      query={query}
      allowSearch={true}
      autoFocus={false}
      allowPaging={true}
      renderActions={renderActions}
    >
      {({ data }) => <SegmentsTable data={data} />}
    </DataGrid>
  );
}